<!DOCTYPE html>
<html lang="en" class="bg-gray-100">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Scramble Options</title>
    <link href="./libs/tw-output.css" rel="stylesheet">
</head>
<body class="font-sans text-gray-900 antialiased">
    <div class="max-w-3xl mx-auto p-6 bg-white shadow-lg rounded-lg mt-10">
        <h1 class="text-3xl font-bold text-gray-900 mb-4">Scramble settings</h1>
        <p class="text-gray-700 mb-8">
            Scramble is an open-source Chrome extension that leverages AI to enhance your writing directly in your browser. It's designed to be a more customizable and privacy-respecting alternative to Grammarly.
        </p>

        <h2 class="text-2xl font-semibold text-gray-800 mt-8 mb-4">LLM configuration</h2>
        <div class="space-y-4">
            <label class="block">
                <span class="text-gray-700">LLM Provider:</span>
                <select id="llmProvider" class="mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50">
                    <option value="openai">OpenAI</option>
                    <option value="anthropic">Anthropic</option>
                    <option value="ollama">Ollama (Local)</option>
                    <option value="lmstudio">LM Studio (Local)</option>
                    <option value="groq">Groq</option>
                    <option value="openrouter">OpenRouter</option>
                </select>
            </label>
            <label class="block">
                <span class="text-gray-700">API Key:</span>
                <input type="text" id="apiKey" placeholder="Enter your API key" class="mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50">
                <small id="apiKeyHelp" class="text-gray-500 text-sm mt-1 block"></small>
            </label>
            <label class="block">
                <span class="text-gray-700">LLM Model:</span>
                <div class="flex gap-2">
                    <input type="text" id="llmModel" placeholder="Enter the LLM model (e.g., gpt-3.5-turbo)" class="mt-1 flex-1 rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50">
                    <button id="fetchModels" type="button" class="mt-1 px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:bg-gray-400 disabled:cursor-not-allowed">
                        <span id="fetchModelsText">Fetch Models</span>
                        <span id="fetchModelsSpinner" class="hidden">⟳</span>
                    </button>
                </div>
                <small id="modelHelp" class="text-gray-500 text-sm mt-1 block"></small>
                <select id="availableModels" class="mt-2 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 hidden">
                    <option value="">Select a model...</option>
                </select>
            </label>
            <label class="block">
                <span class="text-gray-700">Custom Endpoint (optional):</span>
                <input type="text" id="customEndpoint" placeholder="Enter custom API endpoint URL" class="mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50">
                <small id="endpointHelp" class="text-gray-500 text-sm mt-1 block"></small>
            </label>
        </div>
        
        <h2 class="text-2xl font-semibold text-gray-800 mt-8 mb-4">Custom prompts</h2>
        <div id="prompts-container" class="space-y-4"></div>
        <button id="add-prompt" class="mt-4 px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 font-bold">Add prompt</button>

        <div id="status" class="mt-6 text-sm text-gray-700"></div>
        <div class="flex justify-center">
            <button id="save" class="mx-auto mt-6 px-4 py-2 bg-indigo-600 text-white font-bold rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">Save changes</button>
        </div>
    </div>
    
    <script src="options.js"></script>

    <template id="prompt-template">
        <div class="prompt-container bg-gray-100 p-4 rounded-lg border border-gray-300">
            <label class="block mb-2">
                <span class="text-gray-700">Prompt Title:</span>
                <input type="text" class="prompt-title mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="Enter prompt title">
            </label>
            <label class="block mb-2">
                <span class="text-gray-700">Prompt:</span>
                <textarea class="prompt-text mt-1 block w-full rounded-md border border-gray-300 bg-white px-3 py-2 shadow-sm focus:border-indigo-500 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" placeholder="Enter your prompt here" rows="3"></textarea>
            </label>
            <div class="prompt-actions mt-2">
                <button class="delete-prompt px-4 py-2 bg-red-600 text-white font-bold rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2">Delete</button>
            </div>
        </div>
    </template>
</body>
</html>